import { createApp } from 'vue'
import App from '@/App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//@ts-expect-error  忽略当前文件ts类型的检测否则有红色提示(打包会失败)
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 引入elementsIcon插件
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 引入 src/components/index.ts 文件,通过 app.use 方法安装自定义插件
import gloablComponent from './components/index.js'
//svg 图标使用
import 'virtual:svg-icons-register'
// 样式
import '@/styles/index.scss'
//测试mock接口能否使用
// import axios from 'axios'
//登陆接口
// axios({
//   url: '/api/user/login',
//   method: 'post',
//   data: {
//     username: 'admin',
//     password: '111111',
//   },
// })

const app = createApp(App)

// 关键：将 PascalCase 转换为 el-icon-短横线格式
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  const kebabName = key.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase() // 例如 AddLocation → add-location
  app.component(`el-icon-${kebabName}`, component) // 注册为 <el-icon-add-location>
}

app.use(ElementPlus, {
  locale: zhCn,
})

app.use(gloablComponent)

app.mount('#app')

console.log(import.meta.env)
